<template>
    <main-wrap style="background: #fcf7ee;">
        <div style="width: 6rem;margin-bottom: 10px"><Button text="获取公司服务专家列表" @click="getExperts"/></div> 
        <div style="width: 4rem;margin-bottom: 10px"><Button text="发布问题" @click="questionAdd"/></div> 
        <div style="width: 4rem;margin-bottom: 10px"><Button text="获取咨询列表" @click="getQuestionList"/></div> 
        <div style="width: 4rem;margin-bottom: 10px"><Button text="获取一条咨询" @click="getOneQa"/></div>
        <div style="width: 4rem;margin-bottom: 10px"><Button text="咨询回复列表" @click="getReplayList"/></div>
        <div style="width: 4rem;margin-bottom: 10px"><Button text="添加回复" @click="replayAdd"/></div>
    </main-wrap>
</template>

<script>
import { mapGetters } from "vuex";
import Request from '@/utils/request'
import mainWrap from 'cps/public/mainWrap'
import Button from 'cps/public/Button'

export default {
    components:{
        mainWrap,
        Button
    },
    data(){
        return{
            
        }
    },
    computed: {
        ...mapGetters({
             //userInfo:'user/userInfo',
        }),
    },
    async created(){
        /**
         * 提供给甲方的参数appid:为companyToCustoms表的_id
         * 
         */
        
    },
    mounted(){
        
    },
    methods:{  
        getExperts(){
            // 1、专家列表:companyId: "", // 固定，提供给甲方
            Request.post('/api/get/server-experts?companyId=66bd6815430e3aef2486e9f1')
            .then(res =>{
                console.log(res.data)
            })
        },
        questionAdd(){
            //  2、新增问题（咨询）
            Request.post('/api/question-add?appid=66bd6815430e3aef2486e9f2',{
                external_userid:'10001', // 外部用户id（即客户公司自己小程序的用户id）
                title: "816测试问题4", // 固定，提供给甲方
                questionContent:'816问题详情问题详情问题详情4',
                classifyIds:['64006888c989cf5754c27028'], // 分类id数组
                annex:[{name:'dddd.png',url:'http://api.ej12366.video/upload/5e8c1c87c2a20b38d871cec2/6ydZWnQ0USVBDNvOv9fNs7eh.png'}]  // 对象数组:[{name:'',url:''}] name文件名包括后缀，url文件链接
            })
            .then(res =>{
                console.log(res.data)
            })
        },
        getQuestionList(){
            Request.post('/api/get/questions?appid=66bd6815430e3aef2486e9f2',{
                pageSize:10,
                pageIndex:1,
                sort:{createTime: -1}
            })
            .then(res =>{
                console.log(res.data)
            })
        },
        getOneQa(){
            Request.get('/api/get/question/66bea940993b34fa3522d3da?appid=66bd6815430e3aef2486e9f2')
            .then(res =>{
                console.log(res.data)
            })
        },
        getReplayList(){
            Request.post('/api/get/replies?appid=66bd6815430e3aef2486e9f2',{
                pageSize:10,
                pageIndex:1,
                questionId:'66bef05696cdc1fdc731c0f0',//'665d99e35b8280559870ec91',
                //sort:{createTime: -1}
            })
            .then(res =>{
                console.log(res.data)
            })
        },
        replayAdd(){
            // external_userid,type,annex,content,questionId,commentId
            Request.post('/api/reply-add?appid=66bd6815430e3aef2486e9f2',{
                external_userid:'10002', // 外部用户id（即客户公司自己小程序的用户id）
                type:4, // 2普通用户对问题进行回复，4对评论进行回复(此时commentId必填)
                //annex:[{name:'dddd.png',url:'http://api.ej12366.video/upload/5e8c1c87c2a20b38d871cec2/6ydZWnQ0USVBDNvOv9fNs7eh.png'}],
                content:'明白了，感谢！',
                questionId:'66bef05696cdc1fdc731c0f0',
                commentId:'66bef0df96cdc1fdc731c0f4'
            })
            .then(res =>{
                console.log(res.data)
            })
        }
    }
}
</script>

<style lang="scss" scoped>
   
</style>
